package com.cqie.rbac.mapper;

import com.cqie.rbac.entity.EvaluationView;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cqie.rbac.vo.OptionsVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * VIEW Mapper 接口
 * </p>
 *
 * @author 单机吧
 * @since 2021-10-13
 */
@Mapper
public interface EvaluationViewMapper extends BaseMapper<EvaluationView> {
    /**
     * 题目
     * @param quotaId
     * @return
     */
    @Select("SELECT DISTINCT\n" +
            "\tevaluation_view.quota_id, \n" +
            "\tevaluation_view.quota_name\n" +
            "FROM\n" +
            "\tevaluation_view\n" +
            "WHERE\n" +
            "\tquota_id = #{quotaId}")
    EvaluationView getQuotaByQuotaId(@Param("quotaId") Long quotaId);

    /**
     * 选项
     * @param quotaId
     * @return
     */
    @Select("SELECT\n" +
            "\tevaluation_view.option_id,\n" +
            "\tevaluation_view.option_name, \n" +
            "\tevaluation_view.option_score\n" +
            "FROM\n" +
            "\tevaluation_view\n" +
            "WHERE quota_id = #{quotaId}")
    List<OptionsVo> getOptionByQuotaId(@Param("quotaId") Long quotaId);
}
